Type Set
解説を書いた→ https://zenn.dev/nobishii/articles/99a2b55e2d3e50
#Go言語
proposal: spec: generics: use type sets to remove type keyword in constraints
https://github.com/golang/go/issues/45346
Context
もともとの発端はもちろんGo言語のType Parameterのproposal
accepted https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md
このproposalでは型制約をinterface型で表現することになっている
しかしinterface型は定義上method setなので、「<で比較できる」というような広義のインターフェースを表現できない
そこでType Listの概念が導入されている
type listを含むinterfaceは型制約の中でしか用いることができないが、将来的に変数の型や関数のシグネチャの型としても用いることができるようにすることが検討されている
その内容のproposalも出された
https://golang.org/issue/41716 sum types using interface type lists
type listをもつinterface型は型制約の中でしか使えないという制約を取り除くproposal
しかしその中で、type listの抱えるわかりにくさや問題点がわかってきた→Type Listの問題点
Type Set概念は、従来のinterfaceがmethod setによって特定されることによる限界を克服してinterface概念を拡張するための概念である
https://github.com/golang/go/issues/45346#issuecomment-812730886
Type Sets Proposal続編に続く